﻿
@page "/Bas/CodingRule/Create"
@using nERP.ViewModel.Bas.CodingRuleVMs
@using System.ComponentModel.DataAnnotations
@inherits BasePage

<div>
  <ValidateForm @ref="vform" Model="@Model" OnValidSubmit="@Submit" >
    <Row ItemsPerRow="ItemsPerRow.Two" RowType="RowType.Normal">
      <Select @bind-Value="@Model.Entity.CodingListId" Items="AllCodingLists" PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]" Id="g8b6a6d45ec584cd7b19029b612c80817"/>
      <BootstrapInput @bind-Value="@Model.Entity.Seq"/>
      <Select @bind-Value="@Model.Entity.CodeRule" PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]" Id="g6c239fb4a98f470f9e3c5cf09e6735f9"/>
      <BootstrapInput @bind-Value="@Model.Entity.FixedValue"/>
      <Select @bind-Value="@Model.Entity.FixedRule" PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]" Id="g1145396717c4450c8e3fe2da0ebca8f7"/>
      <BootstrapInput @bind-Value="@Model.Entity.GlideLen"/>
      <BootstrapInput @bind-Value="@Model.Entity.StartNumber"/>
      <BootstrapInput @bind-Value="@Model.Entity.GlideStep"/>
      <BootstrapInput @bind-Value="@Model.Entity.Glide"/>
    </Row>

    <div class="modal-footer table-modal-footer">
      <Button ButtonType="ButtonType.Submit" IsAsync="true" Text="@WtmBlazor.Localizer["Sys.Submit"]"/>
      <Button OnClick="OnClose" Text="@WtmBlazor.Localizer["Sys.Close"]"/>
    </div>

  </ValidateForm>

</div>



@code {
    [Parameter]
    public string id { get; set; }
    [Parameter]
    public string[] ids { get; set; }
    private CodingRuleVM Model = new CodingRuleVM();
    private ValidateForm vform { get; set; }
    private async Task Submit(EditContext context)
    {
                        
        
        await PostsForm(vform, "/api/Bas/CodingRule/Create", (s) => "Sys.OprationSuccess");
    }
    public void OnClose()
    {
        CloseDialog();
    }
    
    private List<SelectedItem> AllCodingLists = new List<SelectedItem>();
    protected override async Task OnInitializedAsync()
    {
        
        
        AllCodingLists = await WtmBlazor.Api.CallItemsApi("/api/Bas/CodingRule/GetCodingLists");
        AllCodingLists.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });

        await base.OnInitializedAsync();
    }
}
